// withdrawal_success_page.dart
import 'package:flutter/material.dart';

class WithdrawalSuccessPage extends StatefulWidget {
  const WithdrawalSuccessPage({super.key});

  @override
  State<WithdrawalSuccessPage> createState() => _WithdrawalSuccessPageState();
}

class _WithdrawalSuccessPageState extends State<WithdrawalSuccessPage> {
  // 禁用物理返回键
  Future<bool> _onWillPop() async {
    return false;
  }

  void _completeAction() {
    // 返回到首页或指定页面
    Navigator.of(context).popUntil((route) => route.isFirst);
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: _onWillPop,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('提现结果'),
          leading: IconButton(
            icon: const Icon(Icons.arrow_back),
            onPressed: _completeAction, // 自定义返回逻辑
          ),
        ),
        backgroundColor: Colors.white,
        body: _buildContent(),
      ),
    );
  }

  Widget _buildContent() {
    return SingleChildScrollView(
      child: Column(
        children: [
          const SizedBox(height: 60),
          // 成功图标和文字
          _buildSuccessSection(),
          // 完成按钮
          _buildCompleteButton(),
        ],
      ),
    );
  }

  Widget _buildSuccessSection() {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16),
      child: Column(
        children: [
          // 成功图标
          Container(
            width: 101,
            height: 96,
            decoration: BoxDecoration(
              image: const DecorationImage(
                image: AssetImage('assets/images/wode_tixian_chenggong_icon.png'),
                fit: BoxFit.contain,
              ),
            ),
          ),
          const SizedBox(height: 18),
          // 成功标题
          const Text(
            '提现成功',
            style: TextStyle(
              fontSize: 17,
              fontWeight: FontWeight.w500,
              color: Color(0xFF262626),
            ),
          ),
          const SizedBox(height: 8),
          // 成功描述
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 20),
            child: Text(
              '我们将在3个工作日内，将提现现金转入您的支付宝账户。',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 13,
                color: Color(0xFF666666),
                height: 1.5,
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildCompleteButton() {
    return Container(
      padding: const EdgeInsets.all(16),
      margin: const EdgeInsets.only(top: 40),
      child: SizedBox(
        width: double.infinity,
        height: 44,
        child: ElevatedButton(
          style: ElevatedButton.styleFrom(
            backgroundColor: Theme.of(context).colorScheme.primary,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(4),
            ),
            elevation: 0,
          ),
          onPressed: _completeAction,
          child: const Text(
            '完成',
            style: TextStyle(
              fontSize: 15,
              fontWeight: FontWeight.w500,
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }
}